﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Send2Twitter.Addins.TwitterSender2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="SettingWindow"
    Title="SettingWindow" Height="358" Width="496" Icon="PLAY.ico">
	<Window.Resources>
		<local:AuthTypeConverter x:Key="AuthTypeConverter"/>
		<local:Commands x:Key="CommandsDataSource" d:IsDataSource="True"/>
		<local:InvertVisibilityConverter x:Key="InvertVisibilityConverter"/>
		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<local:MySettings x:Key="MySettingsDataSource" d:IsDataSource="True"/>
		<local:NumToStringConverter x:Key="NumToStringConverterDataSource" d:IsDataSource="True"/>
	</Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource NumToStringConverterDataSource}}">
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width="0.167*"/>
    		<ColumnDefinition Width="0.25*"/>
    		<ColumnDefinition Width="0.166*"/>
    		<ColumnDefinition Width="0.167*"/>
    		<ColumnDefinition Width="0.25*"/>
    	</Grid.ColumnDefinitions>
    	<Grid.RowDefinitions>
    		<RowDefinition Height="39.992"/>
    		<RowDefinition/>
    		<RowDefinition Height="39.992"/>
    		<RowDefinition Height="40.04"/>
    		<RowDefinition Height="40"/>
    		<RowDefinition Height="40"/>
    	</Grid.RowDefinitions>
    	<ToggleButton x:Name="toggleButton" Content="{Binding UseOAuth, Converter={StaticResource AuthTypeConverter}}" Margin="8" Grid.Column="1" DataContext="{Binding Source={StaticResource MySettingsDataSource}}" IsChecked="{Binding Default.UseOAuth}">
    		<ToggleButton.Background>
    			<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
    				<LinearGradientBrush.RelativeTransform>
    					<TransformGroup>
    						<ScaleTransform CenterY="0.5" CenterX="0.5"/>
    						<SkewTransform CenterY="0.5" CenterX="0.5"/>
    						<RotateTransform CenterY="0.5" CenterX="0.5"/>
    						<TranslateTransform X="0.496"/>
    					</TransformGroup>
    				</LinearGradientBrush.RelativeTransform>
    				<GradientStop Color="#FFF3F3F3" Offset="0"/>
    				<GradientStop Color="#FFEBEBEB" Offset="0.5"/>
    				<GradientStop Color="#FFDDDDDD" Offset="0.5"/>
    				<GradientStop Color="#FFCDCDCD" Offset="1"/>
    			</LinearGradientBrush>
    		</ToggleButton.Background>
    	</ToggleButton>
    	<Label Content="认证方式：" Margin="8,8,0,0"/>
    	<Grid x:Name="grid" Grid.Row="1" Grid.ColumnSpan="5" DataContext="{Binding Source={StaticResource MySettingsDataSource}}" Visibility="{Binding IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=toggleButton}">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="0.167*"/>
    			<ColumnDefinition Width="0.666*"/>
    			<ColumnDefinition Width="0.167*"/>
    		</Grid.ColumnDefinitions>
    		<Grid.RowDefinitions>
    			<RowDefinition Height="0.333*"/>
    			<RowDefinition Height="0.334*"/>
    			<RowDefinition Height="0.333*"/>
    		</Grid.RowDefinitions>
    		<Label Content="API URL" Margin="8" Grid.Row="2"/>
    		<Label Content="Secret" Margin="8" Grid.Row="1"/>
    		<Label Content="Token" Margin="8"/>
    		<TextBox Margin="8" TextWrapping="Wrap" Text="{Binding Default.Token}" Grid.Column="1"/>
    		<TextBox Margin="8" TextWrapping="Wrap" Text="{Binding Default.TokenSecret}" Grid.Row="1" Grid.Column="1"/>
    		<TextBox Margin="8" TextWrapping="Wrap" Text="{Binding OAuthApiUrl}" Grid.Row="2" Grid.Column="1"/>
    		<Button Content="认证" Margin="8" d:LayoutOverrides="VerticalAlignment" Grid.Column="2" Command="{Binding DoOAuth, Mode=OneWay}" DataContext="{Binding Source={StaticResource CommandsDataSource}}"/>
    	</Grid>
    	<Label Content="代理设置：" Margin="8" Grid.Row="2" d:LayoutOverrides="VerticalMargin"/>
    	<Label Content="代理选择：" Margin="8" Grid.Row="3"/>
    	<Label Content="地址：" Margin="8" Grid.Row="4"/>
    	<Label Content="端口" Margin="8" Grid.Row="5"/>
    	<Label Content="代理验证：" Grid.Column="3" Margin="8" Grid.Row="3"/>
    	<Label Content="用户名：" Grid.Column="3" Margin="8" Grid.Row="4"/>
    	<Label Content="密码：" Grid.Column="3" Margin="8" Grid.Row="5"/>
    	<TextBox Grid.Column="1" Margin="8" Grid.Row="4" TextWrapping="Wrap" Text="{Binding Default.ProxyURL}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}" Grid.ColumnSpan="2"/>
    	<TextBox Grid.Column="1" Margin="8" Grid.Row="5" TextWrapping="Wrap" Text="{Binding Default.ProxyPort}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}" Grid.ColumnSpan="2"/>
    	<TextBox Grid.Column="4" Margin="8" Grid.Row="4" TextWrapping="Wrap" Text="{Binding Default.ProxyUsername}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}"/>
    	<TextBox Grid.Column="4" Margin="8" Grid.Row="5" TextWrapping="Wrap" Text="{Binding Default.ProxyPassword}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}"/>
    	<ComboBox Grid.Column="1" Margin="8" Grid.Row="3" ItemsSource="{Binding ProxyTypes}" SelectedIndex="{Binding Default.ProxyType, Source={StaticResource MySettingsDataSource}}" Grid.ColumnSpan="2">
    		<ComboBox.Background>
    			<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
    				<LinearGradientBrush.RelativeTransform>
    					<TransformGroup>
    						<ScaleTransform CenterY="0.5" CenterX="0.5"/>
    						<SkewTransform CenterY="0.5" CenterX="0.5"/>
    						<RotateTransform CenterY="0.5" CenterX="0.5"/>
    						<TranslateTransform X="0.495" Y="-0.031"/>
    					</TransformGroup>
    				</LinearGradientBrush.RelativeTransform>
    				<GradientStop Color="#FFF3F3F3" Offset="0"/>
    				<GradientStop Color="#FFEBEBEB" Offset="0.5"/>
    				<GradientStop Color="#FFDDDDDD" Offset="0.5"/>
    				<GradientStop Color="#FFCDCDCD" Offset="1"/>
    			</LinearGradientBrush>
    		</ComboBox.Background>
    	</ComboBox>
    	<Grid Grid.ColumnSpan="5" Grid.Row="1" Visibility="{Binding Visibility, Converter={StaticResource InvertVisibilityConverter}, ElementName=grid}">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="0.167*"/>
    			<ColumnDefinition Width="0.666*"/>
    			<ColumnDefinition Width="0.167*"/>
    		</Grid.ColumnDefinitions>
    		<Grid.RowDefinitions>
    			<RowDefinition Height="0.333*"/>
    			<RowDefinition Height="0.334*"/>
    			<RowDefinition Height="0.333*"/>
    		</Grid.RowDefinitions>
    		<Label Content="API URL" Margin="8" Grid.Row="2"/>
    		<Label Content="密码" Margin="8" Grid.Row="1"/>
    		<Label Content="用户名" Margin="8"/>
    		<TextBox Grid.Column="1" Margin="8" TextWrapping="Wrap" Text="{Binding Default.Username}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}"/>
    		<TextBox Grid.Column="1" Margin="8" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Default.Password}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}"/>
    		<TextBox Grid.Column="1" Margin="8" Grid.Row="2" TextWrapping="Wrap" Text="{Binding Default.ApiUrl}" DataContext="{Binding Source={StaticResource MySettingsDataSource}}"/>
    	</Grid>
        
    </Grid>
</Window>
